Ext.ns('AIR2.Import.Resolve');
/***************
 * Import Resolver Source Panel
 *
 * A panel that allows conflict resolution of Source data
 *
 * @param {Object} data
 * @param {String} model
 */
AIR2.Import.Resolve.Source = function(data, model) {
    // Get the resource URL for the source
    var sourceUrl = null;
    if (data.src_uuid) {
        sourceUrl = AIR2.HOMEURL + '/source/' + data.src_uuid + '.json';
    }

    return new AIR2.Import.Resolve.ConflictRow({
        model: 'Source',
        tpl: new Ext.XTemplate(
            '<ul><tpl for=".">' +
                '{[this.formatSrcLink(values)]}' +
                '<tpl if="src_username"><li class="src_username"><b>Username:</b> {src_username}</li></tpl>' +
                '<tpl if="src_first_name"><li class="src_first_name"><b>First:</b> {src_first_name}</li></tpl>' +
                '<tpl if="src_middle_initial"><li class="src_middle_initial"><b>Middle:</b> {src_middle_initial}</li></tpl>' +
                '<tpl if="src_last_name"><li class="src_last_name"><b>Last:</b> {src_last_name}</li></tpl>' +
                '<tpl if="src_pre_name"><li class="src_pre_name"><b>Pre Name:</b> {src_pre_name}</li></tpl>' +
                '<tpl if="src_post_name"><li class="src_post_name"><b>Post Name:</b> {src_post_name}</li></tpl>' +
                '<tpl if="src_channel"><li class="src_channel"><b>Channel:</b> {src_channel}</li></tpl>' +
            '</tpl></ul>',
            {
                compiled:true,
                disableFormats:true,
                formatSrcLink: function(values) {
                    if (!values.tsrc_id) {
                        return '<li><b>'+AIR2.Format.sourceName(values, true)+'</b></li>';
                    }
                    return '';
                }
            }
        ),
        currTitle: 'Current Profile',
        currUrl: sourceUrl,
        currEmptyText: 'New Source',
        newData: data,
        validOps: 'REPLACE|IGNORE'
    });
}